﻿using System.Collections;
using DataAccess;
using Model;

namespace Service
{

    public class WorkOrderService : ServiceBase
    {
        WODataAccess mgr;
        public WorkOrderService()
        {
            mgr = new WODataAccess();
        }
      
        public void SetAuthorizeWorkOrder(int workOrderId)
        {
             mgr.SetAuthorizeWorkOrder(workOrderId);
        }
        public WorkOrder GetWorkOrder(int workOrderId)
        {
            return mgr.GetWorkOrder(workOrderId);
        }
        public WorkOrderTask GetTaskWorkOrder(int taskId)
        {
            return mgr.GetTaskWorkOrder(taskId);
        }
        public void SaveWorkOrder(WorkOrder workOrder)
        {
            mgr.Save(workOrder);
        }
        public void DeleteWorkOrder(int workOrderId)
        {
            mgr.DeleteObject("From WorkOrder where WorkOrderId =" + workOrderId);
        }
        public void DeleteTaskWorkOrder(WorkOrderTask task)
        {
            mgr.Delete(task);
        }
        public void DeleteTasksInWorkOrder(int workOrderId)
        {
            mgr.DeleteObject("From WorkOrderTask  where WorkOrderId =" +workOrderId);
        }
        public void DeleteTask(int taskId)
        {
            mgr.DeleteObject("From WorkOrderTask   where WorkOrderTaskId =" + taskId);
        }
        public IList GetTaskStaus()
        {
            return mgr.GetByOrder(typeof(TaskStatus), TaskStatus.CONST_TASK_STATUS_Label);
        }
        

        public IList GetCriterias()
        {
            return mgr.GetByOrder(typeof(Criteria), Criteria.CONST_CRITERIA_LABEL);
        }
        public IList GetRequestTypes()
        {
            return mgr.GetByOrder(typeof(RequestType), RequestType.CONST_REQUEST_TYPE_LABEL);
        }
        public IList GetProblemTypes()
        {
            return mgr.GetByOrder(typeof(ProblemType), ProblemType.CONST_PROBLEM_TYPE_LABEL);
        }

        public IList GetEquipmentDefectedTypes()
        {
            return mgr.GetByOrder(typeof(DefectedType), DefectedType.CONST_DEFECTED_TYPE_LABEL);
        }
        public Problem IsAlreadyExistProblem(int prbGroupId, string problem)
        {
            return mgr.IsAlreadyExistProblem(prbGroupId, problem);
        }
        public void SaveProblem(Problem problem)
        {
            mgr.Save(problem);
        }
        public void SaveWorkOrderTask(WorkOrderTask workOrderTask)
        {
            mgr.Save(workOrderTask);
        }
        public WorkOrderTask GetWorkOrderTasks(int workOrderId, int taskID)
        {
            return mgr.GetWorkOrderTasks(workOrderId,taskID);
        }



    }
}
